<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/security/tags"  prefix="security" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>     
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List of all Audits</title>
</head>
<body>
	<table>
		<tr>
			<td>
			You are logged in as <b><u><security:authentication property="principal.username"/></u></b>
			</td>
			<td><a href='<spring:url value="/j_spring_security_logout" htmlEscape="true" />'>Logout</a>
			</td>
		</tr>
		<tr>
			<td>
	There are currently ${fn:length(audits)} audits in the system.<a href="newAudit">Add</a>
			</td>
			<td>
			</td>
		</tr>
	</table>
	<c:if test="${!empty audits}">
		<table>
			<tr>
				<th>
					Id
				</th>
				<th>
					Description
				</th>
				<th>
					Recorded On
				</th>
				<th>
					Recorded By
				</th>
				<th>
					Is Error?
				</th>
				
			</tr>
		<c:forEach var="audit" items="${audits}">
			<tr>
				<td> <a href="audit/${audit.id}"> ${audit.id}</a></td>
				<td>${audit.description}</td>
				<td>${audit.recordedDate}</td>
				<td>${audit.recordedBy}</td>
				<td>${audit.error}</td>
			</tr>
		</c:forEach>
		</table>
	</c:if>
</body>
</html>